﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Windows.Forms;
using QT.Windows;

namespace Reminder
{
    public partial class Form1 : Form
    {

        const int CS_DropSHADOW = 0x20000;
        const int GCL_STYLE = (-26);

        public Form1()
        {
            InitializeComponent();

            SafeNativeMethods.SetClassLong(this.Handle, GCL_STYLE, SafeNativeMethods.GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW); //API函数加载，实现窗体边框阴影效果

            WindowsShortcut.Shortcut sc = new WindowsShortcut.Shortcut();

            sc.Path = Application.ExecutablePath;
            sc.WorkingDirectory = Application.StartupPath;
            sc.Description = "桌面提醒";
            string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
            sc.Save(DesktopPath + "/桌面提醒.lnk");
        }

        private void ToolStripMenuItem_Add_Click(object sender, EventArgs e)
        {
            AddNew myDial = new AddNew();
            myDial.ShowDialog();
        }
    }

    [SuppressUnmanagedCodeSecurity]
    internal static class SafeNativeMethods
    {
        //声明Win32 API
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SetClassLong(IntPtr hwnd, int nIndex, int dwNewLong);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int GetClassLong(IntPtr hwnd, int nIndex);
    }
}
